class Solution {
public:
    bool isIsomorphic(string s, string t) {
        if (s.size() != t.size())return 0;
        unordered_map<char, char>mp, mp1;
        int idx = 0;
        for (auto x : t) {
            if (mp.count(s[idx])) {
                if (mp[s[idx]] != x)return 0;
            }
            if (mp1.count(x)) {
                if (mp1[x] != s[idx])return 0;
            }
            mp1[x] = s[idx];
            mp[s[idx++]] = x;
        }
        return 1;
    }
};